package cn.flkj.lucia2coudb.controller;

import cn.flkj.lucia2coudb.entity.Sofa;
import cn.flkj.lucia2coudb.service.CouchdbCRUD;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.CrossOrigin;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * @author : 州长在手 2020/10/21 下午3:48
 */
@CrossOrigin
@RestController
@RequestMapping("/couchdb")
public class CouchdbController {
    final
    CouchdbCRUD couchdbCRUD;

    public CouchdbController(CouchdbCRUD couchdbCRUD) {
        this.couchdbCRUD = couchdbCRUD;
    }

    @PostMapping("/new")
    public String newSofa(Sofa sofa) {
        return couchdbCRUD.newSofa(sofa);
    }

    @PostMapping("/getSofa")
    public Sofa getSofa(String id) {
        return couchdbCRUD.getSofa(id);
    }

    @PostMapping("/updateSofa")
    public Sofa updateSofa(Sofa sofa){
        return couchdbCRUD.updateSofa(sofa);
    }
    @PostMapping("/deleteSofa")
    public void deleteSofa(Sofa sofa){
        couchdbCRUD.deleteSofa(sofa);
    }
}
